﻿
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PS.Engine.GameComponents
{
    public abstract class BaseGameComponent : DrawableGameComponent
    {
        #region Fields

        protected Texture2D texture;
        protected SpriteBatch spriteBatch;
        protected Color color;

        #endregion

        #region Constructors

        internal BaseGameComponent(Game game)
            : base(game)
        {
            Location = Vector2.Zero;
        }

        internal BaseGameComponent(Game game, float x, float y)
            : base(game)
        {
            Location = new Vector2(x, y);
        }

        #endregion

        #region Properties

        internal Vector2 Location { get; set; }

        protected Color Color
        {
            get
            {
                return color;
            }
        }

        #endregion

        #region Lifecycle overrides

        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(texture, Location, Color);
            spriteBatch.End();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
        }

        #endregion
    }
}
